package com.dsteiner.xelavos.client.controller;

import com.dsteiner.widgets.client.Widgets.IHTML;
import com.dsteiner.widgets.client.Widgets.ILazyWidget;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.WidgetListenerAdapter;
import com.dsteiner.widgets.client.controller.PopupOverlayController;
import com.dsteiner.widgets.client.model.PopupOverlayModel;
import com.dsteiner.xelavos.client.ContactWidget.ContactModel;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

public class ContactController {

	private ContactModel contactModel;
	private IHTML contactLink;
	private PopupOverlayModel popupOverlayModel;

	public void registerContactWidget(ILazyWidget contactWidget) {
		contactWidget.addWidgetListener(new WidgetListenerAdapter() {
			@Override
			public void onAttach(IWidget widget) {
			}
		});
	}

	public void registerContactModel(ContactModel contactModel) {
		this.contactModel = contactModel;
	}

	public void registerContactLink(IHTML contactLink) {
		this.contactLink = contactLink;
		contactLink.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				PopupOverlayController.showAtCenter(popupOverlayModel);
			}
		});
	}

	public void registerPopupOverlayModel(PopupOverlayModel popupOverlayModel) {
		this.popupOverlayModel = popupOverlayModel;
	}
}